package com.lazily.string_;


/**
 * @Author:  GZQ
 * @date:  2025/3/8 21:58
 * @description: 两种创建 String 对象的区别 -- 练习题4
 */

public class StringExercise04 {
	// 程序入口
	public static void main(String[] args) {
		Person p1 = new Person();
		p1.name = "John";
		Person p2 = new Person();
		p2.name = "John";

		System.out.println(p1.name.equals(p2.name)); // 比较内容 // T
		System.out.println(p1.name == p2.name); // T
		System.out.println(p1.name == "John"); // T

		String s1 = new String("John");
		String s2 = new String("John");
		System.out.println(s1 == s2); // F
	}
}

class Person {
	public String name;
}